<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Bootstrap Color Picker Sliders</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Bootstrap 3 optimized responsive color selector with HSV, HSL, RGB and CIE-Lch (which supports human perceived lightness) selectors and color swatches.">
    <meta name="author" content="István Ujj-Mészáros">

    <meta itemprop="name" content="Bootstrap Color Picker Sliders">
    <meta itemprop="description" content="Bootstrap 3 optimized responsive color selector with HSV, HSL, RGB and CIE-Lch (which supports human perceived lightness) selectors and color swatches.">
    <meta itemprop="image" content="http://www.virtuosoft.eu/resources/bootstrap-colorpickersliders.png">

    <link rel="shortcut icon" href="libraries/favicon.ico">

    <link href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" type="text/css" media="all">
    <link href="//cdnjs.cloudflare.com/ajax/libs/prettify/r298/prettify.min.css" rel="stylesheet" type="text/css" media="all">
    <link href="demo.css" rel="stylesheet" type="text/css" media="all">
    <link href="src/bootstrap.colorpickersliders.css" rel="stylesheet" type="text/css" media="all">

    <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.2.0/js/bootstrap.min.js"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/prettify/r298/run_prettify.min.js"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/tinycolor/0.11.1/tinycolor.min.js"></script>
    <script src="src/bootstrap.colorpickersliders.js"></script>

  </head>

  <body>
    <div class="container">
      <div class="hero-unit">

        <h1>Bootstrap Color Picker Sliders</h1>

        <a id="link-ghp" class="btn btn-primary" href="https://github.com/istvan-ujjmeszaros/bootstrap-colorpickersliders" target="_blank"><span class="glyphicon glyphicon-link"></span> Github project page</a>
        <a id="link-ghdl" href="https://github.com/istvan-ujjmeszaros/bootstrap-colorpickersliders/archive/master.zip" class="btn btn-primary" title="download"><span class="glyphicon glyphicon-download"></span> Download</a>

      </div>

      <p>
        This plugin is based on <a href="//www.virtuosoft.eu/code/jquery-colorpickersliders/" target="_blank">jQuery Color Picker Sliders</a>, which doesn't need Bootstrap to work.<br>
      </p>

      <h2>Examples</h2>

      <h3>Full featured popover (HSV panel, HSL and RGB sliders, color swatches)</h3>

      This popovers shows all the features in a grouped manner, so the user can choose the preferred color picking method.

      <div class="row">
        <div class="col-md-4">
          <form class="form-vertical" role="form">
            <div class="form-group">
              <label for="small" class="control-label">Full featured popover</label>
              <input type="text" class="form-control" id="full-popover" value="#A6FF00" data-color-format="hex">
            </div>
          </form>
        </div>
      </div>

      <script>
        $("input#full-popover").ColorPickerSliders({
          placement: 'right',
          hsvpanel: true,
          previewformat: 'hex'
        });
      </script>

      <h3>HSV flat</h3>

      <div class="row">
        <div class="col-md-4">
          <div id="hsvflat"></div>
        </div>

        <div class="col-md-8">
          <pre class="prettyprint">
&lt;div id=&quot;hsvflat&quot;&gt;&lt;/div&gt;
&lt;script&gt;
    $(&quot;#hsvflat&quot;).ColorPickerSliders({
        color: &quot;rgb(36, 170, 242)&quot;,
        flat: true,
        sliders: false,
        swatches: false,
        hsvpanel: true
    });
&lt;/script&gt;
          </pre>
          <script>
            $("#hsvflat").ColorPickerSliders({
              color: "rgb(36, 170, 242)",
              flat: true,
              sliders: false,
              swatches: false,
              hsvpanel: true
            });
          </script>

        </div>
      </div>

      <h3>HSL sliders with customizable color swatches (flat rendering)</h3>

      <div class="row">
        <div class="col-md-6">
          <div id="hslflat"></div>
        </div>

        <div class="col-md-6">
          <pre class="prettyprint">
&lt;div id=&quot;hslflat&quot;&gt;&lt;/div&gt;
&lt;script&gt;
    $(&quot;#hslflat&quot;).ColorPickerSliders({
        color: &quot;rgb(36, 170, 242)&quot;,
        flat: true,
        order: {
            hsl: 1,
            preview: 2
        }
    });
&lt;/script&gt;
          </pre>
          <script>
            $("#hslflat").ColorPickerSliders({
              color: "rgb(36, 170, 242)",
              flat: true,
              order: {
                hsl: 1,
                preview: 2
              }
            });
          </script>

        </div>
      </div>

      <h3>Different sizes and color sliders (in bootstrap popovers)</h3>

      <div class="row">
        <div class="col-md-4">
          <form class="form-vertical" role="form" id="size">
            <div class="form-group">
              <label for="small" class="control-label">Small sized HSL</label>
              <input type="text" class="form-control" id="small" value="#adff2f">
            </div>
            <div class="form-group">
              <label for="small" class="control-label">Small sized HSV</label>
              <input type="text" class="form-control" id="smallhsv" value="#2FB6FF">
            </div>
            <div class="form-group">
              <label for="default" class="control-label">Default sized RGB</label>
              <input type="text" class="form-control" id="default" value="#7f7f7f">
            </div>
            <div class="form-group">
              <label for="large" class="control-label">Large sized HSL</label>
              <input type="text" class="form-control" id="large" value="rgb(251, 167, 219)">
            </div>
            <div class="form-group">
              <label for="swatchesonly" class="control-label">Swatches only</label>
              <input type="text" class="form-control" id="swatchesonly">
            </div>
            <div class="form-group">
              <label for="hslswatches" class="control-label">HSL with opdacity and swatches (grouping disabled)</label>
              <input type="text" class="form-control" id="hslswatches" value="hsl(180, 50%, 50%)">
            </div>
          </form>
        </div>

        <div class="col-md-8">
          <pre class="prettyprint">
&lt;input type=&quot;text&quot; class=&quot;form-control&quot; id=&quot;small&quot; value=&quot;#adff2f&quot;&gt;
&lt;input type=&quot;text&quot; class=&quot;form-control&quot; id=&quot;smallhsv&quot; value=&quot;#2FB6FF&quot;&gt;
&lt;input type=&quot;text&quot; class=&quot;form-control&quot; id=&quot;default&quot; value=&quot;#7f7f7f&quot;&gt;
&lt;input type=&quot;text&quot; class=&quot;form-control&quot; id=&quot;large&quot; value=&quot;rgb(251, 167, 219)&quot;&gt;
&lt;input type=&quot;text&quot; class=&quot;form-control&quot; id=&quot;swatchesonly&quot;&gt;
&lt;input type=&quot;text&quot; class=&quot;form-control&quot; id=&quot;hslswatches&quot; value=&quot;hsl(180, 50%, 50%)&quot;&gt;
&lt;script&gt;
  $(&quot;input#small&quot;).ColorPickerSliders({
    size: 'sm',
    placement: 'right',
    swatches: false,
    order: {
      hsl: 1
    }
  });
  $(&quot;input#smallhsv&quot;).ColorPickerSliders({
    size: 'sm',
    placement: 'right',
    swatches: false,
    sliders: false,
    hsvpanel: true
  });
  $(&quot;input#default&quot;).ColorPickerSliders({
    placement: 'right',
    swatches: false,
    order: {
      rgb: 1
    }
  });
  $(&quot;input#large&quot;).ColorPickerSliders({
    size: 'lg',
    placement: 'right',
    swatches: false,
    order: {
      hsl: 1
    }
  });
  $(&quot;input#swatchesonly&quot;).ColorPickerSliders({
    placement: 'right',
    color: 'red',
    swatches: ['red', 'green', 'blue'],
    customswatches: false,
    order: {}
  });
  $(&quot;input#hslswatches&quot;).ColorPickerSliders({
    placement: 'right',
    grouping: false,
    order: {
      hsl: 1,
      opacity: 2
    }
  });
&lt;/script&gt;
          </pre>

          <script>
            $("input#small").ColorPickerSliders({
              size: 'sm',
              placement: 'right',
              swatches: false,
              order: {
                hsl: 1
              }
            });
            $("input#smallhsv").ColorPickerSliders({
              size: 'sm',
              placement: 'right',
              swatches: false,
              sliders: false,
              hsvpanel: true
            });
            $("input#default").ColorPickerSliders({
              placement: 'right',
              swatches: false,
              order: {
                rgb: 1
              }
            });
            $("input#large").ColorPickerSliders({
              size: 'lg',
              placement: 'right',
              swatches: false,
              order: {
                hsl: 1
              }
            });
            $("input#swatchesonly").ColorPickerSliders({
              placement: 'right',
              color: 'red',
              swatches: ['red', 'green', 'blue'],
              customswatches: false,
              order: {}
            });
            $("input#hslswatches").ColorPickerSliders({
              placement: 'right',
              grouping: false,
              order: {
                hsl: 1,
                opacity: 2
              }
            });
          </script>

        </div>
      </div>

      <h3>Using the <code>onchange()</code> event</h3>

      <div class="row">
        <div class="col-md-4">
          <button class="btn btn-default" id="bgcolor">Change body bg color</button>
        </div>
        <div class="col-md-8">
          <pre class="prettyprint">
&lt;button class=&quot;btn btn-default&quot; id=&quot;bgcolor&quot;&gt;Change body bg color&lt;/button&gt;
&lt;script&gt;
        $(&quot;#bgcolor&quot;).ColorPickerSliders({
            color: 'white',
            previewontriggerelement: false,
            title: 'Body background color',
            order: {
                rgb: 1,
                preview: 2
            },
            onchange: function(container, color) {
                var body = $('body');

                body.css(&quot;background-color&quot;, color.tiny.toRgbString());

                if (color.cielch.l &lt; 60) {
                    body.css(&quot;color&quot;, &quot;white&quot;);
                }
                else {
                    body.css(&quot;color&quot;, &quot;black&quot;);
                }
            }
        });
&lt;/script&gt;
          </pre>
        </div>
        <script>
          $("#bgcolor").ColorPickerSliders({
            color: 'white',
            previewontriggerelement: false,
            title: 'Body background color',
            order: {
              rgb: 1,
              preview: 2
            },
            onchange: function(container, color) {
              var body = $('body');

              body.css("background-color", color.tiny.toRgbString());

              if (typeof color.cielch !== "undefined" && color.cielch.l < 60) {
                body.css("color", "white");
              }
              else {
                body.css("color", "black");
              }
            }
          });
        </script>
      </div>

      <h3>Full featured flat rendering</h3>

      <p>This example shows the CIE Lch sliders which is designed to approximate human vision. It means that yellow and blue with the same CIE lightness are identical to humans (which is not the case with HSL where blue seems to be much darker than yellow with the same HSL lightness).</p>
      <p>CIE Lch is a special color model where not all colors are reproducible in the physical world, so this plugin just lowers the chroma of these colors to be convertible to RGB. You can read more about it on <a href="http://en.wikipedia.org/wiki/Lab_color_space#Advantages" target="_blank">Wikipedia</a>.</p>

      <div class="row">
        <div class="col-md-6">
          <div id="flat"></div>
        </div>

        <div class="col-md-6">
          <pre class="prettyprint">
&lt;div id=&quot;flat&quot;&gt;&lt;/div&gt;
&lt;script&gt;
    $(&quot;#flat&quot;).ColorPickerSliders({
        flat: true,
        invalidcolorsopacity: 0
    });
&lt;/script&gt;
          </pre>
          <code>invalidcolorsopacity</code> hiddens the colors from the CIE sliders whose can not be converted to RGB without lowering their chroma values. It is good for creating color schemas.
          <script>
            $("#flat").ColorPickerSliders({
              flat: true,
              invalidcolorsopacity: 0
            });
          </script>

        </div>
      </div>

      <h2>Settings</h2>
      <table class="table table-striped table-bordered docs">
        <thead>
          <tr>
            <th>Option</th>
            <th>Description</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td><code>color</code></td>
            <td>This is the initial color if there is no valid (any CSS formatted) color value on the connected input element. Can be in any format that <a href="https://github.com/bgrins/TinyColor" target="_blank">Tiny Color supports</a>.</td>
          </tr>
          <tr>
            <td><code>size</code></td>
            <td><code>'sm'</code>: Small sized popover.<br>
              <code><strong>'default'</strong></code>: Default popover size.<br>
              <code>'large'</code>: Large popover.</td>
          </tr>
          <tr>
            <td><code>placement</code></td>
            <td>Popover placement direction. Can be <code><strong>'auto'</strong></code> | <code>'top'</code> | <code>'left'</code> | <code>'bottom'</code> | <code>'right'</code></code>.<br>
              When <code>'auto'</code> is specified, it will dynamically reorient the popover. For example, if placement is <code>'auto left'</code>, the tooltip will display to the left when possible, otherwise it will display right.</tr>
          <tr>
            <td><code>title</code></td>
            <td><code><strong>''</strong></code>: Popover title.</td>
          </tr>
          <tr>
            <td><code>hsvpanel</code></td>
            <td><code><strong>false</strong></code>: Enable/disable HSV color selector panel.</td>
          </tr>
          <tr>
            <td><code>sliders</code></td>
            <td><code><strong>true</strong></code>: Enable/disable the sliders.</td>
          </tr>
          <tr>
            <td><code>grouping</code></td>
            <td><code><strong>true</strong></code>: Enable/disable grouping of the HSV panel, Sliders and Swatches section.</td>
          </tr>
          <tr>
            <td><code>trigger</code></td>
            <td><code>'focus'</code>: The popover will be visible on focus or on click.<br>
              <code>'manual'</code>: No auto trigger of popover on focus/click. Must trigger <code>colorpickersliders.show</code> and <code>colorpickersliders.hide</code> events to show/hide the popover.</td>
          </tr>
          <tr>
            <td><code>flat</code></td>
            <td><code><strong>false</strong></code>: The color picker is rendered in a popup, which is shown on focus of the connected element.<br>
              <code>true</code>: The color picker is rendered right after the connected element, and is always visible.</td>
          </tr>
          <tr>
            <td><code>previewformat</code></td>
            <td>This is the color format on the preview slider (if visible). Can be <strong><code>rgb</code></strong>, <code>hsl</code> or <code>hex</code>. Note that hex format can not represent the opacity value.</td>
          </tr>
          <tr>
            <td><code>swatches</code></td>
            <td><code>array</code>: Array of CSS colors (can be CSS color names as well).<br>
              <code>false</code>: The swatches are disabled.</td>
          </tr>
          <tr>
            <td><code>customswatches</code></td>
            <td><code>string</code>: Name of the custom swatches group. Color pickers with the same <code>customswatches</code> name share the same swatch colors, so if you add a new color to one of the color pickers, then all the color pickers swatches will be updated on the page which has the same <code>customswatches</code> name.<br>
              <code>false</code>: The custom swatches are disabled, so only the predefined swatches can be used.</td>
          </tr>
          <tr>
            <td><code>connectedinput</code></td>
            <td><code><strong>selector or jQuery object</strong></code>: The connected input elements value will be automatically updated in sync with the color picker. The color format which the color is represented i the input can be set via the <code>data-color-format</code> property. It can be any of <code>hex</code>, <code>hsl</code> or <code>rgb</code>. If it is hex, then the opacity will be discarded.</td>
          </tr>
          <tr>
            <td><code>updateinterval</code></td>
            <td>Update interval of the sliders while dragging (ms). The default is 30.</td>
          </tr>
          <tr>
            <td><code>previewontriggerelement</code></td>
            <td><code><strong>true</strong></code>: Preview of the color on the connected element's background.<br>
              <code>false</code>: No preview on the connected element.</td>
          </tr>
          <tr>
            <td><code>previewcontrasttreshold</code></td>
            <td><code><strong>30</strong></code>: If <code>previewontriggerelement</code> is enabled, then if the lightness is below of this value, the element's text color will be white. Otherwise the text is black.</td>
          </tr>
          <tr>
            <td><code>erroneousciecolormarkers</code></td>
            <td><code><strong>true</strong></code>: Unconvertable CIE colors are marked with an exclamation mark on the CIE sliders level marker.<br>
              <code>false</code>: No exclamation mark on the markers.</td>
          </tr>
          <tr>
            <td><code>invalidcolorsopacity</code></td>
            <td><code><strong>1</strong></code>: Opacity of the invalid (unconvertable) area of the CIE sliders.</td>
          </tr>
          <tr>
            <td><code>finercierangeedges</code></td>
            <td><code><strong>true</strong></code>: Sharper, more accurate edges of the valid CIE ranges on the sliders.<br>
              <code><strong>false</strong></code>: Smoother edges of the valid CIE ranges on the sliders.</td>
          </tr>
          <tr>
            <td><code>order</code></td>
            <td>An object which defines which sliders appear and in which order.<br>
              Possible properties: <code>opacity</code>, <code>hsl</code>, <code>rgb</code>, <code>cie</code>, <code>preview</code>.</td>
          </tr>
          <tr>
            <td><code>labels</code></td>
            <td>An object which defines the labels of the sliders.<br>
              Possible properties: <code>hslhue</code>, <code>hslsaturation</code>, <code>hsllightness</code>, <code>rgbred</code>, <code>rgbgreen</code>, <code>rgbblue</code>, <code>cielightness</code>, <code>ciechroma</code>, <code>ciehue</code>, <code>opacity</code>, <code>preview</code>.</td>
          </tr>
          <tr>
            <td><code>onchange</code></td>
            <td><code>function(container, color)</code>: This function is triggered when the color is changed with the sliders or via a connected input. The <code>color</code> parameter holds the actual color object in the following formats: rgb object, hsl object, cie lch object, <a href="https://github.com/bgrins/TinyColor" target="_blank">Tiny Color</a> object.</td>
          </tr>
          <tr>
            <td><code>titleswatchesadd</code></td>
            <td><code>string</code>: Title of the add color to swatches button.</td>
          </tr>
          <tr>
            <td><code>titleswatchesreset</code></td>
            <td><code>string</code>: Title of the reset swatches button.</td>
          </tr>
        </tbody>
      </table>

      <h2>Events</h2>
      <p>
        Example usage: <code>$("#colorpicker").trigger("colorpickersliders.updateColor", "red"));</code>
      </p>

      <p>
        The following events can be triggered on the element which the color picker is initialized on.
      </p>

      <table class="table table-striped table-bordered docs">
        <thead>
          <tr>
            <th>Event</th>
            <th>Description</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td><code>colorpickersliders.updateColor</code></td>
            <td><code>function(newcolor)</code>: Sets a new color for the color picker.</td>
          </tr>
          <tr>
            <td><code>colorpickersliders.show</code></td>
            <td><code>function()</code>: Shows the popover.</td>
          </tr>
          <tr>
            <td><code>colorpickersliders.hide</code></td>
            <td><code>function()</code>: Hiddens the popover.</td>
          </tr>
        </tbody>
      </table>

      <h2>Download</h2>
      <p><a id="link-ghd" href="https://github.com/istvan-ujjmeszaros/bootstrap-colorpickersliders" target="_blank">Download</a> from github. Please report issues and suggestions to github's issue tracker or contact me on <a id="link-gp" href="https://plus.google.com/101242556570448529330/posts" target="_blank">g+</a> or <a id="link-tw" href="https://twitter.com/styu007" target="_blank">twitter</a>!</p>

    </div>

